package com.procurement.bidding.controller;

import com.procurement.bidding.domain.PcmBiddingMiddle;
import com.procurement.bidding.service.PcmBiddingMiddleService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import org.apache.xmlbeans.impl.xb.xsdschema.Public;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/middle")
public class PcmBiddingMiddleController extends BaseController {
    @Autowired
    private PcmBiddingMiddleService pbms;

    @PostMapping("/addBiddingMiddle")
    public AjaxResult addBiddingMiddle(@RequestBody Map<String, Object> map) {
        return toAjax(pbms.addBiddingMiddle(map));
    }

    @GetMapping("/showAllByMiddleNumberName")
    public TableDataInfo showAllByMiddleNumberName(@RequestParam Map<String,Object> map){
        startPage();
        List<PcmBiddingMiddle> pcmBiddingMiddles = pbms.showAllByMiddleNumberName(map);
        return getDataTable(pcmBiddingMiddles);
    }

    /**
     * 邀标审核通过
     * @param map
     * @return
     */
    @PostMapping("examinePassThrough")
    public AjaxResult examinePassThrough(@RequestBody Map<String,Object> map){
        //修改状态-》添加供应商报名待办
        return toAjax(pbms.bidInvitationReviewPassed(map));
    }

    @PostMapping("/showAllByMiddleMainById")
    public PcmBiddingMiddle showAllByMiddleMainById(@RequestBody Long middleId) {
        return pbms.showAllByMiddleMainById(middleId);
    }

    @PostMapping("/selApplicationGys")
    public PcmBiddingMiddle selApplicationGys(@RequestBody Long middleId) {
        return pbms.selApplicationGys(middleId);
    }
    @PostMapping("/isApplicationGys")
    public Boolean isApplicationGys(@RequestBody Map<String, Object> map) {
        return pbms.isApplicationGys(map)>0;
    }

    //根据供应商用户联表登录用户id查询供应商参加的招标信息
    @PostMapping("/selByUserId")
    public TableDataInfo selByUserId(@RequestBody Map<String,Object> map){
        startPage();
        List<Map<String, Object>> maps = pbms.selByUserId(map);
        return getDataTable(maps);
    }
    @PostMapping("/selByMiddleIdTouBio")
    public PcmBiddingMiddle selByMiddleIdTouBio(@RequestBody Long middleId) {
        return pbms.selByMiddleIdTouBio(middleId);
    }

    @PostMapping("/selByMiddleIdExpert")
    public PcmBiddingMiddle selByMiddleIdExpert(@RequestBody Map<String,Object> map) {
        return pbms.selByMiddleIdExpert(map);
    }

    @PostMapping("/selOpening")
    public TableDataInfo selOpening(@RequestParam Map<String,Object> map){
        System.out.println("map"+map);
        startPage();
        List<Map<String, Object>> selOpenings = pbms.selOpening(map);
        return getDataTable(selOpenings);
    }


}
